from plzkeepthat.common import constants as app
from datetime import date, timedelta
from plzkeepthat.models.util.dbutils import get_all_notes_before,\
    delete_note
import logging

two_months = date.today() - timedelta(weeks = app.DELETION_DELTA_WEEKS)
logging.info("Starting CleanUp process. Every Note created before %s " % str(two_months))
count = 0
for note in get_all_notes_before(two_months):
    if delete_note(note):
        ++count
    
if count > 0:
    logging.info("Successfully deleted %d old Notes" % count)
else:
    logging.info("No old Notes found")
    
